<?php

namespace app\common\validate\crm;

use think\Validate;

/**
 * 功能介绍:费用输入验证表单
 * @author lvyubing
 * @date 2022/7/29
 * @copyright ©2022 泉州市盛筑信息科技有限公司 版权所有
 */
class Contacts extends Validate
{
    protected $rule = [
        'customer_id' => 'require',
        'customer_id_name' => 'require',
        'mobile' => 'require|mobile',
        'email' => 'require|email',
        'weichat' => 'alphaDash',
        'telephone' => 'telephone',
    ];
    protected $message = [
        'customer_id.require' => '请选择客户',
        'customer_id_name.require' => '请选择客户',
        'mobile.mobile' => '请输入正确手机号码',
        'mobile.require' => '请输入正确手机号码',
        'email.email' => '请输入正确邮箱格式',
        'email.require' => '请输入邮箱',
        'weichat.alphaDash' => '请输入正确的微信格式',
        'telephone.telephone' => '请输入正确的固定格式号码'
    ];

    protected function telephone($value)
    {
        return preg_match("/[0-9]{4}-?[0-9]{8}/", $value) ? true : "请输入正确的固定格式号码";
    }
}